package com.example.mybatisplusstudy.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import javafx.util.converter.LocalDateTimeStringConverter;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author code威
 * @version 1.0
 * @description: TODO
 * @date 2022/5/4 16:04
 */
@Component
@Slf4j
public class MapperHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("插入语句开始");
        this.strictInsertFill(metaObject,"createdDate", LocalDateTime.class,LocalDateTime.now());
        this.strictInsertFill(metaObject,"updatedDate", LocalDateTime.class,LocalDateTime.now());

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("更新语句开始");
        this.strictUpdateFill(metaObject,"updatedDate", LocalDateTime.class,LocalDateTime.now());


    }
}
